#ifndef TABLEVIEWBASE_H
#define TABLEVIEWBASE_H

#include <QObject>

class TableHeaderViewBase : public QHeaderView
{
     Q_OBJECT

public:
    TableHeaderViewBase( Qt::Orientation orientation, QWidget * parent );
    virtual ~TableHeaderViewBase();

signals:
    void contextMenu( const QPoint & pos );

private:
    virtual void contextMenuEvent( QContextMenuEvent * event );
};

class TableItemDelegateBase : public QItemDelegate
{
    Q_OBJECT

public:
    TableItemDelegateBase( const TableHeaderViewBase & tableHeaderViewBase, QObject * parent );
    virtual ~TableItemDelegateBase();

protected:
    virtual void drawFocus( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect ) const;

private:
    const TableHeaderViewBase & m_tableHeaderViewBase;
};

class TableViewBase : public QTableView
{
    Q_OBJECT

public:
    TableViewBase( QWidget * parent );
    virtual ~TableViewBase();
    void init();
    void selectRowByData( QVariant & data );
    void saveHeaderViewState( const QString & headerViewName ) const;
    void restoreHeaderViewState( const QString & headerViewName );
    TableHeaderViewBase & horizontalHeaderView();

signals:
    void contextMenu( const QPoint & pos, const QModelIndex & modelIndex );
    void contextMenuMultiSelection( const QPoint & pos, const QModelIndexList & modelIndexList );

private slots:
    void onHeaderContextMenu( const QPoint & pos );

private:
    virtual void _init();
    virtual void contextMenuEvent( QContextMenuEvent * event );

protected:
    void setVerticalHeaderView();
    void setHorizontalHeaderView();

protected:
    TableHeaderViewBase m_horizontalHeaderView;
};


#endif // TABLEVIEWBASE_H
